import React, { Component } from "react";
import PubSub from 'pubsub-js';

export default class Search extends Component {
    render() {
        return (
            <div className="search">
                <input ref={el => this.keyword = el} type="text" placeholder="输入您的关键字" />
                <button onClick={this.search}>搜索</button>
            </div>
        );
    }

    search = () => {
        //获取关键字 
        let keyword = this.keyword.value;
        //发布至频道
        PubSub.publish('hero', keyword);
    }

}
